package org.force4spring.support;

import java.rmi.RemoteException;
import java.util.Calendar;
import java.util.List;

import com.sforce.soap.partner.DeleteResult;
import com.sforce.soap.partner.DescribeGlobalResult;
import com.sforce.soap.partner.DescribeLayoutResult;
import com.sforce.soap.partner.DescribeSObjectResult;
import com.sforce.soap.partner.DescribeSoftphoneLayoutResult;
import com.sforce.soap.partner.DescribeTabSetResult;
import com.sforce.soap.partner.Email;
import com.sforce.soap.partner.GetDeletedResult;
import com.sforce.soap.partner.GetServerTimestampResult;
import com.sforce.soap.partner.GetUpdatedResult;
import com.sforce.soap.partner.GetUserInfoResult;
import com.sforce.soap.partner.LeadConvert;
import com.sforce.soap.partner.LeadConvertResult;
import com.sforce.soap.partner.MergeRequest;
import com.sforce.soap.partner.MergeResult;
import com.sforce.soap.partner.ProcessRequest;
import com.sforce.soap.partner.ProcessResult;
import com.sforce.soap.partner.ResetPasswordResult;
import com.sforce.soap.partner.SaveResult;
import com.sforce.soap.partner.SearchResult;
import com.sforce.soap.partner.SendEmailResult;
import com.sforce.soap.partner.SetPasswordResult;
import com.sforce.soap.partner.UndeleteResult;
import com.sforce.soap.partner.UpsertResult;
import com.sforce.soap.partner.fault.ApiFault;
import com.sforce.soap.partner.fault.InvalidFieldFault;
import com.sforce.soap.partner.fault.InvalidIdFault;
import com.sforce.soap.partner.fault.InvalidNewPasswordFault;
import com.sforce.soap.partner.fault.InvalidQueryLocatorFault;
import com.sforce.soap.partner.fault.InvalidSObjectFault;
import com.sforce.soap.partner.fault.MalformedQueryFault;
import com.sforce.soap.partner.fault.MalformedSearchFault;
import com.sforce.soap.partner.fault.UnexpectedErrorFault;

/**
 * 1) Transparent creation of SoapBindingStub and login
 * 2) Caching support
 * 
 * @author Max Rudman
 */
public interface ForceSession {
	public boolean isOpen();
	
	public void clear();
	
	public void flush() throws RemoteException, ApiFault;
	
	public void close() throws RemoteException, ApiFault;
	
	public void setAutoFlush(boolean autoFlush);
	
	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#convertLead(com.sforce.soap.partner.LeadConvert[])
	 */
	public LeadConvertResult[] convertLead(LeadConvert[] leadConverts) throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#create(com.sforce.soap.partner.sobject.SObject[])
	 */
	public SaveResult[] create(SObjectDynaBean[] objects) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault, InvalidIdFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#delete(java.lang.String[])
	 */
	public DeleteResult[] delete(String[] ids) throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#describeGlobal()
	 */
	public DescribeGlobalResult describeGlobal() throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#describeLayout(java.lang.String, java.lang.String[])
	 */
	public DescribeLayoutResult describeLayout(String type, String[] recordTypeIds) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#describeSObject(java.lang.String)
	 */
	public DescribeSObjectResult describeSObject(String type) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#describeSObjects(java.lang.String[])
	 */
	public DescribeSObjectResult[] describeSObjects(String[] types) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#describeSoftphoneLayout()
	 */
	public DescribeSoftphoneLayoutResult describeSoftphoneLayout() throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#describeTabs()
	 */
	public DescribeTabSetResult[] describeTabs() throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#getDeleted(java.lang.String, java.util.Calendar, java.util.Calendar)
	 */
	public GetDeletedResult getDeleted(String type, Calendar start, Calendar end) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#getServerTimestamp()
	 */
	public GetServerTimestampResult getServerTimestamp() throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#getUpdated(java.lang.String, java.util.Calendar, java.util.Calendar)
	 */
	public GetUpdatedResult getUpdated(String type, Calendar start, Calendar end) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#getUserInfo()
	 */
	public GetUserInfoResult getUserInfo() throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#merge(com.sforce.soap.partner.MergeRequest[])
	 */
	public MergeResult[] merge(MergeRequest[] mergeRequests) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault, InvalidIdFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#process(com.sforce.soap.partner.ProcessRequest[])
	 */
	public ProcessResult[] process(ProcessRequest[] processRequests) throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#query(java.lang.String)
	 */
	public List query(String soql) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault, MalformedQueryFault, InvalidFieldFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#queryAll(java.lang.String)
	 */
	public List queryAll(String soql) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault, MalformedQueryFault, InvalidFieldFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#queryMore(java.lang.String)
	 */
	public List queryMore(String queryLocator) throws RemoteException, UnexpectedErrorFault, InvalidQueryLocatorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#resetPassword(java.lang.String)
	 */
	public ResetPasswordResult resetPassword(String userId) throws RemoteException, UnexpectedErrorFault, InvalidIdFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#retrieve(java.lang.String, java.lang.String, java.lang.String[])
	 */
	public SObjectDynaBean[] retrieve(String fields, String type, String[] ids) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault, InvalidFieldFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#search(java.lang.String)
	 */
	public SearchResult search(String sosl) throws RemoteException, MalformedSearchFault, UnexpectedErrorFault, InvalidSObjectFault, InvalidFieldFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#sendEmail(com.sforce.soap.partner.Email[])
	 */
	public SendEmailResult[] sendEmail(Email[] emails) throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#setPassword(java.lang.String, java.lang.String)
	 */
	public SetPasswordResult setPassword(String userId, String password) throws RemoteException, UnexpectedErrorFault, InvalidIdFault, InvalidNewPasswordFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#undelete(java.lang.String[])
	 */
	public UndeleteResult[] undelete(String[] ids) throws RemoteException, UnexpectedErrorFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#update(com.sforce.soap.partner.sobject.SObject[])
	 */
	public SaveResult[] update(SObjectDynaBean[] objects) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault, InvalidIdFault;

	/**
	 * @see com.sforce.soap.partner.SoapBindingStub#upsert(java.lang.String, com.sforce.soap.partner.sobject.SObject[])
	 */
	public UpsertResult[] upsert(String externalIdField, SObjectDynaBean[] objects) throws RemoteException, UnexpectedErrorFault, InvalidSObjectFault, InvalidIdFault, InvalidFieldFault;

	/**
	 * Returns value of 'credentials' property
	 * 
	 * @return credentials property
	 */
	public ForceCredentials getCredentials();

	/**
	 * Sets value of 'credentials' proprty to specified value.
	
	 * @param credentials New value.
	 */
	public void setCredentials(ForceCredentials credentials);
}
